<template>
  <view class="container">
    <uni-forms ref="form" :modelValue="form" labelWidth="120px" labelPosition="top">
      <view class="hidden-title">检修执行确认</view>
    </uni-forms>
    <view class="submit-group">
      <button class="u-button" :ripple="true" @click="submit">确定</button>
    </view>
    <Signature ref="signature" @success="onSignatureSuccess" />
  </view>
</template>

<script>
import Signature from '../signature/signature.vue'
import { pursue } from '@/api/repair/repair.js'

export default {
  components: {
    Signature
  },
  data() {
    return {
      form: {},
      id: '',
      procTaskId: '',
      executeSignature: 'abcdefg'
    }
  },
  onLoad(option) {
    if (!option.data) return
    let data = JSON.parse(option.data)
    this.id = data.id
    this.procTaskId = data.procTaskId
  },
  methods: {
    submit() {
      this.$refs.signature.open()
    },
    onSignatureSuccess(tempFilePath) {
      this.executeSignature = tempFilePath
      let data = {
        deviceExamineWorkflowEntity: {
          examineId: this.id,
          opinionType: 'PASS'
        },
        id: this.id,
        procTaskId: this.procTaskId,
        pursueInfo: {
          executeSignature: this.executeSignature
        }
      }
      pursue(data).then((res) => {
        this.$modal.showToast('处理成功')
        uni.$emit('refresh')
        uni.navigateBack()
      })
    }
  }
}
</script>

<style lang="scss">
.container {
  margin-bottom: 200rpx;

  .background-white {
    background-color: #fff;
    padding: 20rpx 30rpx;
    box-sizing: border-box;

    .uni-forms-item__label {
      color: #333;
      font-size: 30rpx;
    }

    .bor-btm {
      display: flex;
      border-bottom: 1px solid #d5d7e3;
    }

    .photo {
      display: flex;
      justify-content: space-between;

      image {
        width: 214rpx;
        height: 214rpx;
      }
    }

    .text {
      padding-bottom: 20rpx;
      padding-top: 4rpx;
      color: #333;

      text {
        color: #666;
      }
    }
  }
}

.hidden-title {
  background: #f5f5f5;
  padding: 20rpx;
  color: #999;
}

.bor-top {
  border-top: 20rpx solid #f5f5f5;
}

.blue {
  color: #88b4c4;
}

.icon-style {
  width: 52rpx;
  height: 42rpx;
  padding-right: 10rpx;
}
.input {
  display: inline-block;
  width: 100%;
  background-color: #f5f5f5;
  padding: 20rpx;
  font-size: 28rpx;
  border-radius: 10rpx;
  height: 60rpx;
}
</style>
